<template>
    <div class="search">
        <div @click="returnPage" class="hd">
            <i class="iconfont icon-close"></i>
        </div>
        <div class="bd">
            <div class="searchBox">
                <input v-model="text" type="text" name="keywords">
                <i class="iconfont icon-search" @click="goSearch(text)"></i>
            </div>
        </div>
    </div>
</template>

<script>
import {createNamespacedHelpers} from 'vuex'
const {mapActions,mapState,mapMutations} = createNamespacedHelpers('search')
export default {
  data() {
    return {
      text:''
    }
  },
  methods: {
    ...mapActions(['toSearch']),
    goSearch(text){
      this.toSearch(text).then(arr=>{
        this.$router.push({name:'Searchshops',params:{obj:JSON.stringify(arr)}})
      })
    },

    returnPage() {
      this.$router.back(-1)
    }
  },
  computed: {
    ...mapState(['searchTxt'])
  },
}
</script>

<style scoped>
.search .hd {
  height: 40px;
  background: #ff3838;
  position: relative;
  text-align: center;
  line-height: 40px;
}
.search .hd .icon-close {
  position: absolute;
  right: 0;
  color: #fff;
  font-size: 26px;
  width: 40px;
  font-weight: bold;
}
.search .bd {
  padding: 3.2px 9.6px;
  background-color: #ddd;
  height: 48px;
  position: relative;
}
.searchBox {
  position: relative;
  top: 6.4px;
  width: 100%;
  background: #fff;
  border-radius: 20px;
  text-align: center;
}
.searchBox input {
  width: 85%;
  height: 32px;
  line-height: normal;
  border: none;
  font-size: 13px;
  outline: none;
}
.searchBox i {
  color: #ddd;
  font-size: 20px;
  font-weight: bold;
  position: absolute;
  top: 4.4px;
  right: 9.6px;
  width: 19px;
  height: 19px;
  border: none;
}
</style>
